package cn.ffcs.uec.payroll.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cn.ffcs.uec.payroll.dao.UecPayRollDao;
import cn.ffcs.uec.payroll.model.UecPayRoll;
import cn.ffcs.uom.common.constants.BaseUnitConstants;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("uecPayRollDao")
@Transactional
public class UecPayRollDaoImpl extends BaseDaoImpl implements UecPayRollDao {

	@Override
	public PageInfo queryPageInfoByUecPayRoll(UecPayRoll uecPayRoll, int current,
			int pageSize) {
		if (null != uecPayRoll) {
			StringBuilder sb = new StringBuilder(
					" SELECT * FROM UEC_PAYROLL T WHERE T.STATUS_CD = ? ");
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			if (!StrUtil.isEmpty(uecPayRoll.getBillname())) {
				sb.append(" AND T.BILLNAME like ? ");
				params.add("%" + StringEscapeUtils.escapeSql(uecPayRoll.getBillname()) + "%");
			}
			if (null != uecPayRoll.getBillcode()) {
				sb.append(" AND T.BILLCODE like ? ");
				params.add("%" + StringEscapeUtils.escapeSql(uecPayRoll.getBillcode()) + "%");
			}
			return this.jdbcFindPageInfo(sb.toString(), params, current,
					pageSize, UecPayRoll.class);
		}
		return null;
	}

}
